import { Redirect, Route } from "react-router"
import { isAuth } from "../../helpers/auth"

function PrivataAdmin({component:Component},...rest) {
  const auth = isAuth()
  return (
    <Route
      {...rest}
      render={props =>{
        if(auth && auth.user.role === 1) return <Component {...props} />
        return <Redirect to="/signin" />
      }}
    />
  )
}

export default PrivataAdmin